﻿using System;
using System.Collections.Generic;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.nodes.mssql;

namespace SharpSqlAnalyzer.stmt.mssql
{
	// Token: 0x02000169 RID: 361
	public class TMssqlCreateProcedure : TStoredProcedureSqlStatement
	{
		// Token: 0x06000C6B RID: 3179 RVA: 0x00307579 File Offset: 0x00305779
		public TMssqlCreateProcedure(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstmssqlcreateprocedure;
		}

		// Token: 0x06000C6C RID: 3180 RVA: 0x0030758A File Offset: 0x0030578A
		internal override void buildsql()
		{
		}

		// Token: 0x06000C6D RID: 3181 RVA: 0x0030758C File Offset: 0x0030578C
		internal override void clear()
		{
		}

		// Token: 0x06000C6E RID: 3182 RVA: 0x0030758E File Offset: 0x0030578E
		internal override string getasprettytext()
		{
			return "";
		}

		// Token: 0x06000C6F RID: 3183 RVA: 0x00307595 File Offset: 0x00305795
		internal virtual void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x17000246 RID: 582
		// (get) Token: 0x06000C71 RID: 3185 RVA: 0x003075A0 File Offset: 0x003057A0
		// (set) Token: 0x06000C70 RID: 3184 RVA: 0x00307597 File Offset: 0x00305797
		public virtual List<TProcedureOption> ProcedureOptions
		{
			get
			{
				return this.procedureOptions;
			}
			set
			{
				this.procedureOptions = value;
			}
		}

		// Token: 0x17000247 RID: 583
		// (get) Token: 0x06000C73 RID: 3187 RVA: 0x003075B1 File Offset: 0x003057B1
		// (set) Token: 0x06000C72 RID: 3186 RVA: 0x003075A8 File Offset: 0x003057A8
		public virtual bool ForReplication
		{
			get
			{
				return this.isForReplication;
			}
			set
			{
				this.isForReplication = value;
			}
		}

		// Token: 0x17000248 RID: 584
		// (get) Token: 0x06000C74 RID: 3188 RVA: 0x003075B9 File Offset: 0x003057B9
		public override TObjectName StoredProcedureName
		{
			get
			{
				return this.procedureName;
			}
		}

		// Token: 0x17000249 RID: 585
		// (get) Token: 0x06000C75 RID: 3189 RVA: 0x003075C1 File Offset: 0x003057C1
		// (set) Token: 0x06000C76 RID: 3190 RVA: 0x003075C9 File Offset: 0x003057C9
		public virtual TObjectName ProcedureName
		{
			get
			{
				return this.procedureName;
			}
			set
			{
				this.procedureName = value;
			}
		}

		// Token: 0x06000C77 RID: 3191 RVA: 0x003075D4 File Offset: 0x003057D4
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			if (!(this.rootNode is TCreateProcedureSqlNode))
			{
				return -1;
			}
			TCreateProcedureSqlNode tcreateProcedureSqlNode = (TCreateProcedureSqlNode)this.rootNode;
			base.doParseStatement(psql);
			this.procedureName = tcreateProcedureSqlNode.ProcedureName;
			base.DatabaseObjects.Add(this.procedureName);
			this.ParameterDeclarations = tcreateProcedureSqlNode.Parameters;
			this.procedureOptions = tcreateProcedureSqlNode.ProcedureOptions;
			this.isForReplication = tcreateProcedureSqlNode.ForReplication;
			if (this.ParameterDeclarations != null)
			{
				for (int i = 0; i < this.ParameterDeclarations.size(); i++)
				{
					this.TopStatement.SymbolTable.Push(new TSymbolTableItem(9, this, this.ParameterDeclarations.getParameterDeclarationItem(i)));
				}
			}
			if (tcreateProcedureSqlNode.Stmts != null)
			{
				tcreateProcedureSqlNode.Stmts.doParse(this, ESqlClause.unknown);
				for (int j = 0; j < tcreateProcedureSqlNode.Stmts.size(); j++)
				{
					this.BodyStatements.add(tcreateProcedureSqlNode.Stmts.getStatementSqlNode(j).Stmt);
				}
			}
			if (this.ParameterDeclarations != null)
			{
				for (int k = 0; k < this.ParameterDeclarations.size(); k++)
				{
					this.TopStatement.SymbolTable.Pop();
				}
			}
			return 0;
		}

		// Token: 0x06000C78 RID: 3192 RVA: 0x00307708 File Offset: 0x00305908
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000C79 RID: 3193 RVA: 0x00307718 File Offset: 0x00305918
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.ParameterDeclarations != null)
			{
				this.ParameterDeclarations.acceptChildren(v);
			}
			if (this.BodyStatements.size() > 0)
			{
				this.BodyStatements.acceptChildren(v);
			}
			v.postVisit(this);
		}

		// Token: 0x040012E0 RID: 4832
		private List<TProcedureOption> procedureOptions;

		// Token: 0x040012E1 RID: 4833
		private bool isForReplication;

		// Token: 0x040012E2 RID: 4834
		private TObjectName procedureName;
	}
}
